#include<bits/stdc++.h>
#define int long long
using namespace std;
const int M = 600000;
long long f[M+11];
int n,m;
typedef struct{
	int c,t,w;
}AD;
bool cmp(AD A,AD B)
{
	return A.w * B.t < B.w * A.t;
}
AD a[111];
pair<int,long long> q[M+11];
int l,r;
long long s[111],sw[111],ans;
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	freopen("book.in","r",stdin);
	freopen("book.out","w",stdout);
	cin >> n;
	for(int i = 1;i <= n;i++)
		cin >> a[i].c;
	for(int i = 1;i <= n;i++)
		cin >> a[i].t;
	for(int i = 1;i <= n;i++)
		cin >> a[i].w;
	cin >> m;
	sort(a + 1,a + n + 1,cmp);
	for(int i = n;i;i--)
		s[i] = s[i + 1] + (a[i].c * a[i].t),sw[i] = sw[i + 1] + (a[i].c * a[i].w);
	for(int i = 1;i <= n;i++)
	{
		if(s[i + 1] <= m)
		{
			int k = min((m - s[i + 1]) / a[i].t,a[i].c);
			while(k >= 0 && m - (s[i + 1] + k * a[i].t) <= M)
			{
				ans = max(ans,sw[i + 1] + f[m - (s[i + 1] + k * a[i].t)] + k * a[i].w);
				k--;
			}
		}
		for(int b = 0;b < a[i].t;b++)
		{
			q[l = 0] = {0,f[b]},r = 1;
			for(int v = b + a[i].t,k = 1;v <= M;v += a[i].t,k++)
			{
				while(l < r && q[l].first < k - a[i].c) l++;
				while(l < r && q[r - 1].second + ((k - q[r - 1].first) * a[i].w) < f[v]) r--;
				q[r++] = {k,f[v]};
				f[v] = q[l].second + ((k - q[l].first) * a[i].w);
			}
		}
	}
	cout << ans;
	return 0;
}
